-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat: improve ssr html mismatch validation #10658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 28d5bf4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! A few small tweaks, other than that 👍
packages/svelte/tests/runtime-runes/samples/invalid-html-ssr/_config.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Simon H <[email protected]>
Co-authored-by: Simon H <[email protected]>
'which may result in content being shifted around and will likely result in a hydration mismatch.'; | ||
// eslint-disable-next-line no-console | ||
console.error(message); | ||
payload.head.out += `<script>console.error(${message})</script>`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing quotes around ${message}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s already a string though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but you're generating code (the script tag), and in code strings must be quoted (you probably need to sanitize the message for the quotes you'll be using too...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, published a fix
This provides HTML validation for during DEV when we server side render the content. If any errors are found we
console.error
both on the server and on the client (we inject a<script>
tag with theconsole.error
into the head).